﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XiaoYuJi.Entity.BusEntitys;
using XiaoYuJi.Entity.SysEntitys;

namespace XiaoYuJi.EntityFrameworkCore;
public class SqlDbContext : DbContext
{
    /// <summary>
    /// 
    /// </summary>
    /// <param name="options">数据库连接字符串</param>
    public SqlDbContext(DbContextOptions options)
        : base(options)
    {

    }

    #region 系统表
    public virtual DbSet<SysUser> SysUsers { get; set; }    //用户表
    public virtual DbSet<SysMenu> SysMenus { get; set; }    //菜单权限表
    public virtual DbSet<SysRole> SysRoles { get; set; }    //角色表
    public virtual DbSet<SysRoleMenu> SysRoleMenus { get; set; }    //角色菜单对应关系表



    #endregion

    #region 业务表
    public virtual DbSet<Picture> Pictures { get; set; }    //图片表
    public virtual DbSet<Classify> Classifys { get; set; }    //分类表
    public virtual DbSet<Article> Articles { get; set; }    //文章表



    #endregion

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        //全局关闭EF Core数据跟踪
        optionsBuilder.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);

        base.OnConfiguring(optionsBuilder);
    }

}
